import math

class Point:
    def __init__(self,x,y):
        self.x = x
        self.y = y

    def __add__(self, other):
        '''返回一个新的Point 对象，其坐标为前面两个Point 对象对应坐标的和'''
        newx = self.x + other.x
        newy = self.y + other.y
        return Point(newx,newy)

    def __sub__(self, other):
        '''返回两个点之间的距离'''
        dx = self.x - other.x
        dy = self.y - other.y
        return (dx * dx + dy * dy) ** 0.5

    def __mul__(self, n):
        '''返回一个新的Point 对象，其坐标为当前点坐标与标量 n 的乘积'''
        newx = self.x * n
        newy = self.y * n
        return Point(newx,newy)

    def __neg__(self):
        '''一元负号'''
        newx = -self.x
        newy = -self.y
        return Point(newx,newy)

    def __trunc__(self):
        '''截断方法'''
        newx = self.x.__trunc__()
        newy = self.y.__trunc__()
        return Point(newx,newy)

    def __iadd__(self, other):
        '''就地运算符 +='''
        self.x += other.x
        self.y += other.y
        return self

    def __imul__(self, other):
        self.x *= other
        self.y *= other
        return self


pt1 = Point(10,15)
pt2 = Point(0,5)
x = pt1 + pt2

pt3 = Point(5.5,-6.6)
pt4 = pt3.__trunc__()
print(pt4.x,', ',pt4.y,sep='')


class Points:
    def __init__(self, x=0, y=0):
        self.x = x
        self.y = y

    def __int__(self):
        return int(self.x) + int(self.y)

    def __float__(self):
        return float(self.x) + float(self.y)


p = Points(1,2.5)
int(p)   # 3
float(p)  # 3.5

